from APP.database import db
from sqlalchemy.dialects.mysql import INTEGER

class ApplicationLog(db.Model):
    __tablename__ = 'application_logs'

    id = db.Column(INTEGER(unsigned=True), primary_key=True, autoincrement=True)
    timestamp = db.Column(db.DateTime, nullable=False)
    source = db.Column(db.String(255), nullable=False)
    pid = db.Column(INTEGER(unsigned=True), nullable=True)
    log_level = db.Column(db.Enum('DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'), nullable=True)
    message = db.Column(db.Text, nullable=False)

    __table_args__ = (
        db.Index('idx_timestamp', 'timestamp'),
        db.Index('idx_source', 'source'),
        db.Index('idx_pid', 'pid'),
    )
